Technical Q&As


OPS18 - Detecting Control Strip at Startup (19-Oct-98)


Q Under Mac OS 8.5, when I call the Control Strip API at boot time the Mac crashes. I have verified that ControlStripDispatch is implemented. What is the source of the crash?

A Any extension calling the Control Strip software should be sure that the Control Strip exists and is loaded before it attempts to make any call to it. Just checking that ControlStripDispatch trap is implemented is insufficient.

Starting with Mac OS 8.5, Control Strip is an application and is not loaded at startup time. Therefore extensions cannot make Control Strip calls (such as SPBShowHideControlStrip) at startup time. Calling Control Strip routines when Control Strip is not running will cause a crash.

The proper way for an application or extension to determine if it is safe to call Control Strip is to use Gestalt with the gestaltControlStripAttr selector and check that the gestaltControlStripExists bit is set, which indicates that Control Strip and its complete API is available. The following code shows how to do this:

static Boolean IsControlStripAvailable (void) {
    OSStatus err;
    long response;
    
    err = Gestalt (gestaltControlStripAttr, response);
    if (response & (1 << gestaltControlStripExists)) {
        // It is safe to call Control Strip
        return true;
    } else {
        // It is not safe to call Control Strip
        return false;
    }
}



-- Mark Cookson
Worldwide Developer Technical Support

Technical Q&As
Previous Question | Next Question
Contents

To contact us, please use the Contact Us page.